<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>表单输入绑定</title>
</head>

<body>
    <!-- 文本 -->
    <div id="exmaple-1">
        <input v-model="message" placeholder="edit me">
        <p>Message is {{message}}</p>
    </div>
    <!-- 多行文本 -->
    <div id="example-2">
        <span>Multiline message is:</span>
        <p style="white-space:pre-line">{{message}}</p>
        <br>
        <textarea v-model="message" placeholder="add multiple lines"></textarea>
    </div>
    <!-- 复选框 -->
    <div id="example-3">
        <input type="checkbox" id="jack" value="jack" v-model="checkedNames">
        <label for="jack">Jack</label>
        <input type="checkbox" id="john" value="john" v-model="checkedNames">
        <label for="john">John</label>
        <input type="checkbox" id="mike" value="mike" v-model="checkedNames">
        <label for="mike">Mike</label>
        <br>
        <span>Checked names: {{checkedNames}}</span>
    </div>
    <!-- 单选按钮 -->
    <div id="example-4">
        <input type="radio" id="one" value="One" v-model="picked">
        <label for="one">One</label>
        <br>
        <input type="radio" id="two" value="Two" v-model="picked">
        <label for="two">Two</label>
        <br>
        <span>Picked:{{picked}}</span>
    </div>
    <!-- 选择框：单选时 -->
    <div id="example-5">
        <select v-model="selected">
            <option disabled value="">请选择</option>
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <span>Selected:{{selected}}</span>
    </div>
    <!-- 选择框：多选时 -->
    <div id="example-6">
        <select v-model="selected" multiple style="width: 100px">
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <span>Selected:{{selected}}</span>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        new Vue({
            el: "#exmaple-1",
            data: {
                message: ''
            }
        })
        new Vue({
            el: '#example-2',
            data: {
                message: ""
            }
        })
        new Vue({
            el: "#example-3",
            data: {
                checkedNames: []
            }
        })
        new Vue({
            el: "#example-4",
            data: {
                picked: ''
            }
        })
        new Vue({
            el: "#example-5",
            data: {
                selected: ''
            }
        })
        new Vue({
            el: '#example-6',
            data: {
                selected: []
            }
        })
    </script>
</body>

</html>